package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveLabelSearchList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_label_search_list, json);
    }

    public static List<String> getLabelSearchList() {
        String json = sSpUtils.getString(Key.key_label_search_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    public static void saveLocationSearchList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_location_search_list, json);
    }

    public static List<String> getLocationSearchList() {
        String json = sSpUtils.getString(Key.key_location_search_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    interface Key {
        String key_label_search_list = "key_label_search_list";
        String key_location_search_list = "key_location_search_list";
    }
}